VOWELS = {"a", "e", "i", "o", "u"}


class Solution:
    def countVowels(self, word: str) -> int:
        size = len(word)

        ans = 0

        i, j = 0, size - 1
        now = 0

        while i <= j:
            now += size - 2 * i
            if i != j:
                if word[i] in VOWELS:
                    ans += now
                if word[j] in VOWELS:
                    ans += now
            else:
                if word[i] in VOWELS:
                    ans += now

            i += 1
            j -= 1

        return ans


if __name__ == "__main__":
    print(Solution().countVowels(word="aba"))  # 6
    print(Solution().countVowels(word="abc"))  # 3
    print(Solution().countVowels(word="ltcd"))  # 0
    print(Solution().countVowels(word="noosabasboosa"))  # 237
